package com.magic.core;

import java.util.Date;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.ext.handler.UrlSkipHandler;
import com.jfinal.json.MixedJsonFactory;
import com.jfinal.kit.Prop;
import com.jfinal.kit.PropKit;
import com.jfinal.template.Engine;
import com.magic.kit.DateKit;

/**
 * 核心配置
 * 
 * @author Jason Yang
 * @datetime 2017年6月5日 下午3:04:09
 */
public class CoreConfig extends JFinalConfig {
	private static Prop p;

	public static void main(String[] args) {
		JFinal.start("WebContent", 8765, "/", 5);
	}

	public void configConstant(Constants me) {
		// 如果生产环境配置文件存在，则优先加载该配置，否则加载开发环境配置文件
		p = PropKit.use("config.txt");
		me.setDevMode(p.getBoolean("devMode"));
		me.setJsonFactory(new MixedJsonFactory());
	}

	public void configRoute(Routes me) {
	}

	public void configPlugin(Plugins me) {
	}

	public void configInterceptor(Interceptors me) {
	}

	public void configHandler(Handlers me) {
		me.add(new UrlSkipHandler("(/druid/.*)|(/ws)", false));
	}

	@Override
	public void configEngine(Engine me) {
	}
	
	@Override
	public void afterJFinalStart() {
		System.out.println("本次启动于 [" + DateKit.format(new Date()) + "]");
	}


}
